import React from "react";
import { Breadcrumb, Button, Input, Table } from "antd";
import * as XLSX from "xlsx";

const Index = () => {
  const fn = (e) => {
    console.log(e);

    // 固定写法
    const reader = new FileReader();
    reader.readAsBinaryString(e.target.files[0]);

    reader.onload = () => {
      const workbook = XLSX.read(reader.result, { type: "binary" });
      let res = workbook.Sheets["sheet"];
      res = XLSX.utils.sheet_to_json(res);

      console.log(res);
    };
  };

  return (
    <div>
      <div style={{ display: "flex", justifyContent: "space-between" }}>
        <Breadcrumb
          style={{ marginBottom: 20 }}
          items={[
            {
              title: "文件处理",
            },
            {
              title: "excel导入",
            },
          ]}
        />
        <Button>
          <Input
            type="file"
            onChange={fn}
            style={{ width: 80, opacity: 0 }}
          ></Input>
        </Button>

        {/* <Upload onChange={fn}>
          <Button>文件上传</Button>
        </Upload> */}
      </div>

      <Table></Table>
    </div>
  );
};

export default Index;
